import event from '@/axios/event';
// 获取上报事件列表
export const eventPage = data => event.get('/pocEvent/page', { params: data });

// // 获取物资类型详情
// export const getSuppliesType = (id) => $.get(`/suppliesType/get/${id}`);

// // 获取物资列表
// export const suppliesPage = (data) => $.get('/supplies/page', { params: data });

// // 获取物资详情
export const getEvent = id => event.get(`/pocEvent/get/${id}`);

// 事件新建
export const addObj = data => event.post('/pocEvent/save', data);

// 事件修改
export const putObj = data => event.post('/pocEvent/modify', data);

// 事件状态修改
export const putObjStatus = (id, status) =>
  event.get('/pocEvent/modifyStatus/' + id + '/' + status);

//文件下载
export const getFile = url => {
  return new Promise((resolve, reject) => {
    event({
      method: 'get',
      url,
      responseType: 'blob',
    })
      .then(data => {
        resolve(data.data);
      })
      .catch(error => {
        reject(error.toString());
      });
  });
};

// 导出
export const exportExport = data => {
  return new Promise((resolve, reject) => {
    event({
      method: 'get',
      url: '/pocEvent/export',
      responseType: 'blob',
      params: data,
    })
      .then(data => {
        resolve(data.data);
      })
      .catch(error => {
        reject(error.toString());
      });
  });
};

// //单独文件下载
export const getSingleFile = url => event.get(url, { responseType: 'blob' });

//登录物资系统
export const loginMaterials = data =>
  event.get('/login/register', { params: data });
